.TH std::allocator_traits 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::allocator_traits \- std::allocator_traits

.SH Synopsis
   Defined in header <memory>
   template< class Alloc >     \fI(since C++11)\fP
   struct allocator_traits;

   The allocator_traits class template provides the standardized way to access various
   properties of Allocators. The standard containers and other standard library
   components access allocators through this template, which makes it possible to use
   any class type as an allocator, as long as the user-provided specialization of
   std::allocator_traits implements all required functionality.

   A program that declares an explicit or partial specialization of       (since C++23)
   std::allocator_traits is ill-formed, no diagnostic required.

   The default, non-specialized, std::allocator_traits contains the following members:

.SH Member types

   Type                                   Definition
   allocator_type                         Alloc
   value_type                             Alloc::value_type
   pointer                                Alloc::pointer if present, otherwise
                                          value_type*
                                          Alloc::const_pointer if present, otherwise
   const_pointer                          std::pointer_traits<pointer>::rebind<const
                                          value_type>
   void_pointer                           Alloc::void_pointer if present, otherwise
                                          std::pointer_traits<pointer>::rebind<void>
                                          Alloc::const_void_pointer if present,
   const_void_pointer                     otherwise
                                          std::pointer_traits<pointer>::rebind<const
                                          void>
   difference_type                        Alloc::difference_type if present, otherwise
                                          std::pointer_traits<pointer>::difference_type
   size_type                              Alloc::size_type if present, otherwise
                                          std::make_unsigned<difference_type>::type
   propagate_on_container_copy_assignment Alloc::propagate_on_container_copy_assignment
                                          if present, otherwise std::false_type
   propagate_on_container_move_assignment Alloc::propagate_on_container_move_assignment
                                          if present, otherwise std::false_type
   propagate_on_container_swap            Alloc::propagate_on_container_swap if
                                          present, otherwise std::false_type
   is_always_equal                        Alloc::is_always_equal if present, otherwise
                                          std::is_empty<Alloc>::type

.SH Member alias templates

   Type             Definition
                    Alloc::rebind<T>::other if present, otherwise SomeAllocator<T,
   rebind_alloc<T>  Args> if this Alloc is of the form SomeAllocator<U, Args>, where
                    Args is zero or more type arguments
   rebind_traits<T> std::allocator_traits<rebind_alloc<T>>

.SH Member functions

   allocate                              allocates uninitialized storage using the
   \fB[static]\fP                              allocator
                                         \fI(public static member function)\fP
   allocate_at_least                     allocates storage at least as large as the
   \fB[static]\fP (C++23)                      requested size via an allocator
                                         \fI(public static member function)\fP
   deallocate                            deallocates storage using the allocator
   \fB[static]\fP                              \fI(public static member function)\fP
   construct                             constructs an object in the allocated storage
   \fB[static]\fP                              \fI(function template)\fP
   destroy                               destructs an object stored in the allocated
   \fB[static]\fP                              storage
                                         \fI(function template)\fP
   max_size                              returns the maximum object size supported by
   \fB[static]\fP                              the allocator
                                         \fI(public static member function)\fP
   select_on_container_copy_construction obtains the allocator to use after copying a
   \fB[static]\fP                              standard container
                                         \fI(public static member function)\fP

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to          Behavior as published              Correct behavior
   LWG 2108 C++11      there was no way to show an allocator   is_always_equal provided
                       is stateless

.SH See also

   AllocatorAwareContainer  container using allocator; associated traits (e.g.
   \fI(C++11)\fP                  propagate_on_container_swap) usage
                            (named requirement)
   allocator                the default allocator
                            \fI(class template)\fP
   scoped_allocator_adaptor implements multi-level allocator for multi-level containers
   \fI(C++11)\fP                  \fI(class template)\fP
   pointer_traits           provides information about pointer-like types
   \fI(C++11)\fP                  \fI(class template)\fP
